//共用alert confirm弹窗
app.directive('publicAlert',function(){
	return {
		restrict:'E',
		replace : true,
		template:'<div id="ycf-alert" class="modal">'
	            +'<div class="modal-dialog modal-sm">'
	                +'<div class="modal-content">'
	                    +'<div class="modal-header">'
	                        +'<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'
	                        +'<h5 class="modal-title"><i class="fa fa-exclamation-circle"></i> {{alertmsg.Title}}</h5>'
	                    +'</div>'
	                    +'<div class="modal-body small text-center">'
	                        +'<p>{{alertmsg.Message}}</p>'
	                    +'</div>'
	                    +'<div class="modal-footer" >'
	                        +'<button type="button" class="btn btn-primary ok" ng-click="calback()" data-dismiss="modal">确定</button>'
	                        +'<button type="button" ng-if="alertmsg.Type" class="btn btn-default cancel" data-dismiss="modal">取消</button>'
	                    +'</div>'
	                +'</div>'
	            +'</div>'
	        +'</div>',
	        link:function($scope,$element){
	        	$scope.alert=function(data){
	        		if (data.show) {
	        			$scope.alertmsg = data;
	        			if (data.prevId) {
	        				$(data.prevId).one('hidden.bs.modal', function (e) {
								 $element.modal('show');
							})
	        			} else{
	        				$element.modal('show');
	        			}
	        			
	        			
	        		}
	        	}
	        	
	        }
		}
})